
<link rel="stylesheet" type="text/css" href="/css/pinus.css">

<header>
    <div class="h_content">
        <span></span>
    </div>
</header>
<section class="block">
    <div class="content2">
        <div class="app">
            <span class="iphone"><img src="/img/bgpic.jpg" width="100%" height="auto"></span>
            <label class="text_amount">
                <input id="amount" type="text" placeholder="金 额"/>
            </label>
            <div class="ch">
                <span class="up" onclick="wap_pay('upacp_wap')">银联 WAP</span>
                <span class="up" onclick="wap_pay('alipay_wap')">支付宝 WAP</span>
                <span class="up" onclick="wap_pay('wx_wap')">微信 WAP</span>
                <span class="up" onclick="wap_pay('wx_pub')">微信浏览器内公众号支付 WAP</span>

            </div>
        </div>
    </div>
</section>
<script src="/js/pingpp.js" type="text/javascript"></script>
<script>

    function wap_pay(channel) {
        var amount = $('#amount').val()*100;
        var charger = './payment/pay';
        $.ajax({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            type:'post',
            url:charger,
            data:{
                'amount':amount,
                'channel':channel,
                'subject':'长袖',
                'body':'很好看，买买买'
            },
            success:function (charge) {
                console.log(charge);
                pingpp.createPayment(charge, function(result, err){
                    if (result == "success") {
                        // 只有微信公众账号 wx_pub 支付成功的结果会在这里返回，其他的支付结果都会跳转到 extra 中对应的 URL。
                    } else if (result == "fail") {
                        // charge 不正确或者微信公众账号支付失败时会在此处返回
                        console.log(result+" "+err.msg+" "+err.extra);
                    } else if (result == "cancel") {
                        // 微信公众账号支付取消支付
                        console.log('微信公众账号支付取消支付');
                    }
                });
            }

        })
    }
</script>
